<template>
	<el-form-item :prop="`${prtot}.${prop}`" :rules="[
		{
			required: true,
			message: '不能为空',
			trigger: 'change'
		}]">
		<!-- {{ `${prtot}.${name}` }} -->
		<el-input-number :value="value" :controls="false" :min="0" class="num-input" @change="handleChange" />
	</el-form-item>
</template>
<script>
export default {
	props: {
		scope: {
			type: Object,
			default: {}
		},
		updateData: {
			type: Function,
			default: () => { }
		},
		name: {
			type: String,
			default: ''
		}
	},
	computed: {
		prtot() {
			const { row } = this.scope
			return row.name
		},
		prop() {
			if (this.name) {
				return this.name
			}
			const { column, row } = this.scope
			const __prefix = row.__prefix || ''
			return `${__prefix}${column.property}`
		},
		value() {
			const { row } = this.scope
			return row[this.prop]
		}
	},
	methods: {
		handleChange(newVal) {
			this.updateData(newVal, this.prop)
		}
	}
}

</script>

<style scoped>
.num-input {
	width: 120px;
}
</style>
